home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / cycles / objects.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  25.8 KB  |  1,627 lines

  1.  
  2. #include <stdlib.h> /* for rand, RAND_MAX */
  3. #include <math.h>   /* for cos, sin, M_PI */
  4. #include "cycles.h"
  5.  
  6. Object tail_obj, engine_obj, chassis_top;
  7. Object back_stuff[LEVELS];
  8.  
  9. #define WALL_HT_0 (0.5*DIM)
  10. #define WALL_HT_1 DIM
  11. #define WALL_HT_2 DIM
  12.  
  13. void init_circ_data(void);
  14.  
  15. /* bike shape defs */
  16. #define SPOKES
  17. #define WHEEL_WIDTH   CYCLE_WIDTH
  18. #define CHASSIS_WIDTH CYCLE_WIDTH
  19. #ifdef RGB_MODE
  20. #   define SHADED_SPOKES
  21. #endif
  22. #define     GREY100 0x646464
  23. #define     GREY150 0x969696
  24. #define    BIKE_TOP 0x0
  25. #define   BIKE_SIDE 0x0
  26. #define    BIKE_BOT 0xffffff
  27. #define BIKE_WINDOW 0xffffff
  28. #define no_FLAT_SIDES
  29. #define no_OUTLINING
  30. #ifdef SPOKES
  31. #   define NUM_SPOKES 3
  32. #endif
  33. #define CIRC_PTS 18
  34. /*
  35.  * wheel rotation speeds, eg. rear:
  36.  * v/r=theta, radius 1.55,  1/1.55 = 0.645, and 180/pi = 57.3
  37.  * and is in 10ths of degrees so 10* :
  38.  * rot speed = 0.645*57.3*10 = 370
  39.  */
  40. #define ROT_SPEED_REAR  370.0
  41. #define ROT_SPEED_FRONT 409.0
  42.  
  43.  
  44. static float wheel_side[CIRC_PTS][3];
  45. static float wheel_top[3*CIRC_PTS][3];
  46. extern int wheel_angle[CYCLES][2];
  47. extern int trail_col[COLOURS], level_col[LEVELS];
  48. extern POINT up_hole[LEVELS], down_hole[LEVELS];
  49.  
  50. static float rear[8][3]  = {    { 0.4*CHASSIS_WIDTH, 4.4,  0.0},/* back */
  51.                 { 0.3*CHASSIS_WIDTH, 3.8, -0.5},
  52.                 { 0.8*CHASSIS_WIDTH, 2.7, -2.9},/* front */
  53.                 { 0.8*CHASSIS_WIDTH, 3.4, -2.5},
  54.                 {-0.4*CHASSIS_WIDTH, 4.4,  0.0},/* back */
  55.                 {-0.3*CHASSIS_WIDTH, 3.8, -0.5},
  56.                 {-0.8*CHASSIS_WIDTH, 2.7, -2.9},/* front */
  57.                 {-0.8*CHASSIS_WIDTH, 3.4, -2.5} };
  58.  
  59. static float engine[6][3] = {    { 0.9*CHASSIS_WIDTH, 2.7, -5.1},
  60.                 { 0.2*CHASSIS_WIDTH, 0.6, -4.3},/* bot */
  61.                 { 0.5*CHASSIS_WIDTH, 3.3, -2.9},/* back */
  62.                 {-0.2*CHASSIS_WIDTH, 0.6, -4.3},/* bot */
  63.                 {-0.5*CHASSIS_WIDTH, 3.3, -2.9},/* back */
  64.                 {-0.9*CHASSIS_WIDTH, 2.7, -5.1} };
  65.  
  66. static float bubble[15][3] = {    { 0.4*CHASSIS_WIDTH, 3.8, -2.5},/* back */
  67.                 {     CHASSIS_WIDTH, 3.3, -4.4},
  68.                 { 0.5*CHASSIS_WIDTH, 4.7, -4.8},
  69.                 {     CHASSIS_WIDTH, 3.0, -5.5},
  70.                 { 0.5*CHASSIS_WIDTH, 4.6, -6.0},
  71.                 { 0.2*CHASSIS_WIDTH, 3.3, -7.0},/* front */
  72.                 { 0.0, 3.9, -6.9},
  73.                 {-0.2*CHASSIS_WIDTH, 3.3, -7.0},/* front */
  74.                 {-0.5*CHASSIS_WIDTH, 4.6, -6.0},
  75.                 {    -CHASSIS_WIDTH, 3.0, -5.5},
  76.                 {-0.5*CHASSIS_WIDTH, 4.7, -4.8},
  77.                 {    -CHASSIS_WIDTH, 3.3, -4.4},
  78.                 {-0.4*CHASSIS_WIDTH, 3.8, -2.5},/* back */
  79.                 { 0.2*CHASSIS_WIDTH, 3.0, -6.8},/* "chin"... */
  80.                 {-0.2*CHASSIS_WIDTH, 3.0, -6.8} };
  81.  
  82. /*
  83.  * setup data for later circle drawing
  84.  */
  85. void init_circ_data(void) {
  86.     int i;
  87.     float radius = 1.4, x, z;
  88.     double angle;
  89.  
  90.     for (i = 0; i < CIRC_PTS; i++) {
  91.     angle = 2.0*M_PI*(float)i/(float)(CIRC_PTS - 1);
  92.     x = radius*cos(angle);
  93.     z = radius*sin(angle);
  94.  
  95.     /* a wheel side */
  96.     wheel_side[i][0] = 0.0;
  97.     wheel_side[i][1] = x;
  98.     wheel_side[i][2] = z;
  99.  
  100.     /* the tyre */
  101.     wheel_top[i*3][0] = -WHEEL_WIDTH;
  102.     wheel_top[i*3][1] = x;
  103.     wheel_top[i*3][2] = z;
  104.  
  105.     wheel_top[i*3+1][0] = 0.0;
  106.     wheel_top[i*3+1][1] = 1.1*x;
  107.     wheel_top[i*3+1][2] = 1.1*z;
  108.  
  109.     wheel_top[i*3+2][0] = WHEEL_WIDTH;
  110.     wheel_top[i*3+2][1] = x;
  111.     wheel_top[i*3+2][2] = z;
  112.     }
  113. }
  114.  
  115.  
  116. /*
  117.  * define and create all objects to be drawn to the screen
  118.  * during play.
  119.  */
  120. void make_objs(void) {
  121.     int i;
  122.  
  123.     for (i = 0; i < LEVELS; i++) back_stuff[i] = genobj();
  124.     tail_obj = genobj();
  125.     engine_obj = genobj();
  126.     chassis_top = genobj();
  127.  
  128.     init_circ_data();
  129.  
  130.     /*
  131.      * even newer disconnected bubble chassis
  132.      */
  133.     /* rear tail thing */
  134.     makeobj(tail_obj);
  135. #ifdef RGB_MODE
  136.     bgntmesh();
  137.     cpack(0xffff00);
  138.     v3f(rear[2]);
  139.     cpack(0xff00ff);
  140.     v3f(rear[1]);
  141.     cpack(0x00ff00);
  142.     v3f(rear[4]);
  143.     cpack(0xff0000);
  144.     v3f(rear[3]);
  145.     cpack(0x00ffff);
  146.     v3f(rear[6]);
  147.     cpack(0x0000ff);
  148.     v3f(rear[5]);
  149.     v3f(rear[0]);
  150.     cpack(0xff00ff);
  151.     v3f(rear[7]);
  152.     cpack(0xffff00);
  153.     v3f(rear[2]);
  154.     endtmesh();
  155. #else
  156.     color(BLUE);
  157.     bgntmesh();
  158.     v3f(rear[2]);
  159.     v3f(rear[1]);
  160.     v3f(rear[4]);
  161.     v3f(rear[3]);
  162.     v3f(rear[6]);
  163.     v3f(rear[5]);
  164.     v3f(rear[0]);
  165.     v3f(rear[7]);
  166.     v3f(rear[2]);
  167.     endtmesh();
  168. #endif
  169.     closeobj();
  170.  
  171.     /* engine */
  172.     makeobj(engine_obj);
  173.     /* covered front */
  174.     bgntmesh();
  175. #ifdef RGB_MODE
  176.     cpack(GREY100);
  177. #else
  178.     color(BLACK);
  179. #endif
  180.     v3f(engine[2]);
  181. #ifdef RGB_MODE
  182.     cpack(BIKE_SIDE);
  183. #endif
  184.     v3f(engine[1]);
  185.     v3f(engine[0]);
  186.     v3f(engine[3]);
  187.     v3f(engine[5]);
  188. #ifdef RGB_MODE
  189.     cpack(GREY100);
  190. #endif
  191.     v3f(engine[4]);
  192.     endtmesh();
  193.     closeobj();
  194.  
  195.     /* top */
  196.     makeobj(chassis_top);
  197.     bgntmesh();
  198. #ifdef RGB_MODE
  199.     cpack(BIKE_TOP);
  200. #else
  201.     color(BLACK);
  202. #endif
  203.     v3f(bubble[0]);
  204.     v3f(bubble[1]);
  205.     v3f(bubble[2]);
  206.     v3f(bubble[3]);
  207.     v3f(bubble[4]);
  208.     v3f(bubble[5]);
  209. #ifdef RGB_MODE
  210.     cpack(BIKE_WINDOW);
  211. #else
  212.     color(WHITE);
  213. #endif
  214.     v3f(bubble[6]);
  215. #ifdef RGB_MODE
  216.     cpack(BIKE_TOP);
  217. #else
  218.     color(BLACK);
  219. #endif
  220.     v3f(bubble[7]);
  221.     v3f(bubble[8]);
  222.     v3f(bubble[9]);
  223.     v3f(bubble[10]);
  224.     v3f(bubble[11]);
  225.     v3f(bubble[12]); /* end outer */
  226.     endtmesh();
  227.     bgntmesh(); /* top */
  228.     v3f(bubble[0]);
  229.     v3f(bubble[12]);
  230.     v3f(bubble[2]);
  231.     v3f(bubble[10]);
  232. #ifdef RGB_MODE
  233.     cpack(BIKE_WINDOW);
  234. #else
  235.     color(WHITE);
  236. #endif
  237.     v3f(bubble[4]);
  238.     v3f(bubble[8]);
  239.     v3f(bubble[6]);
  240.     endtmesh();
  241.     bgntmesh(); /* chin thing under the front */
  242.     v3f(bubble[3]);
  243. #ifdef RGB_MODE
  244.     cpack(BIKE_TOP);
  245. #else
  246.     color(BLACK);
  247. #endif
  248.     v3f(bubble[5]);
  249.     v3f(bubble[13]);
  250.     v3f(bubble[7]);
  251.     v3f(bubble[14]);
  252. #ifdef RGB_MODE
  253.     cpack(BIKE_WINDOW);
  254. #else
  255.     color(WHITE);
  256. #endif
  257.     v3f(bubble[9]);
  258.     endtmesh();
  259.     closeobj();
  260.  
  261.     /*
  262.      * Draw some background objects around the place
  263.      */
  264.     makeobj(back_stuff[0]);
  265.     {
  266.     float v[3];
  267.  
  268.     zbuffer(FALSE);
  269.  
  270.     v[2] = DIM;
  271.  
  272.     /* draw a big wall up one side */
  273. #ifdef RGB_MODE
  274.     cpack(0x333333);
  275. #else
  276.     color(GREY50);
  277. #endif
  278.     bgntmesh();
  279.     v[0] = -DIM;
  280.     v[1] = 0.0;
  281.     v3f(v);
  282.     v[0] = DIM;
  283.     v3f(v);
  284. #ifdef RGB_MODE
  285.     cpack(0x666666);
  286. #endif
  287.     v[0] = -DIM;
  288.     v[1] = WALL_HT_0;
  289.     v3f(v);
  290.     v[0] = DIM;
  291.     v3f(v);
  292.     endtmesh();
  293.  
  294.     /*
  295.      * then add some interesting shapes and outlines
  296.      */
  297.  
  298.     /* top corner triangle */
  299. #ifdef RGB_MODE
  300.     cpack(0x333333);
  301. #else
  302.     color(GREY25);
  303. #endif
  304.     bgntmesh();
  305.     v[0] = -DIM;
  306.     v[1] = 0.4*WALL_HT_0;
  307.     v3f(v);
  308.     v[1] = WALL_HT_0;
  309.     v3f(v);
  310.     v[0] = -0.6*DIM;
  311.     v3f(v);
  312.     endtmesh();
  313. #ifdef RGB_MODE
  314.     cpack(0xffffff);
  315. #else
  316.     color(WHITE);
  317. #endif
  318.     bgnline();
  319.     v3f(v);
  320.     v[0] = -DIM;
  321.     v[1] = 0.25*DIM;
  322.     v3f(v);
  323.     endline();
  324.  
  325.     /* and tri way out to side */
  326. #ifdef RGB_MODE
  327.     cpack(0x333333);
  328. #else
  329.     color(GREY25);
  330. #endif
  331.     bgntmesh();
  332.     v[0] = -DIM;
  333.     v[1] = 0.4*WALL_HT_0;
  334.     v3f(v);
  335.     v[1] = WALL_HT_0;
  336.     v3f(v);
  337.     v[0] = -6.0*DIM;
  338.     v3f(v);
  339.     endtmesh();
  340. #ifdef RGB_MODE
  341.     cpack(0xffffff);
  342. #else
  343.     color(WHITE);
  344. #endif
  345.     bgnline();
  346.     v3f(v);
  347.     v[0] = -DIM;
  348.     v[1] = 0.25*DIM;
  349.     v3f(v);
  350.     endline();
  351.  
  352.     /* dark triangle */
  353. #ifdef RGB_MODE
  354.     cpack(0x222222);
  355. #else
  356.     color(BLACK);
  357. #endif
  358.     bgntmesh();
  359.     v[0] = -0.3*DIM;
  360.     v[1] = 0.3*WALL_HT_0;
  361.     v3f(v);
  362.     v[0] = 0.0;
  363.     v3f(v);
  364. #ifdef RGB_MODE
  365.     cpack(0);
  366. #endif
  367.     v[1] = 0.8*WALL_HT_0;
  368.     v3f(v);
  369.     endtmesh();
  370.  
  371.     /* hidden stripe */
  372. #ifdef RGB_MODE
  373.     cpack(GREY25);
  374. #else
  375.     color(GREY25);
  376. #endif
  377.     bgntmesh();
  378.     v[0] = 0.2*DIM;
  379.     v[1] = 0;
  380.     v3f(v);
  381.     v[0] = 0.3*DIM;
  382.     v3f(v);
  383.     v[0] = -0.2*DIM;
  384.     v[1] = WALL_HT_0;
  385.     v3f(v);
  386.     v[0] = -0.1*DIM;
  387.     v3f(v);
  388.     endtmesh();
  389.  
  390.     /* stripe */
  391. #ifdef RGB_MODE
  392.     cpack(GREY50);
  393. #else
  394.     color(GREY25);
  395. #endif
  396.     bgntmesh();
  397.     v[0] = -0.8*DIM;
  398.     v[1] = 0;
  399.     v3f(v);
  400.     v[0] = -0.4*DIM;
  401.     v3f(v);
  402.     v[0] = -0.2*DIM;
  403.     v[1] = WALL_HT_0;
  404.     v3f(v);
  405.     v[0] = 0.2*DIM;
  406.     v3f(v);
  407.     endtmesh();
  408.  
  409.     /* double line */
  410. #ifdef RGB_MODE
  411.     cpack(0xffffff);
  412. #else
  413.     color(WHITE);
  414. #endif
  415.     bgnclosedline();
  416.     v[0] = -0.8*DIM;
  417.     v[1] = 0;
  418.     v3f(v);
  419.     v[0] = -0.82*DIM;
  420.     v3f(v);
  421.     v[0] = -0.22*DIM;
  422.     v[1] = WALL_HT_0;
  423.     v3f(v);
  424.     v[0] = -0.2*DIM;
  425.     v3f(v);
  426.     endclosedline();
  427.  
  428.     /* mid wall triangle */
  429. #ifdef RGB_MODE
  430.     cpack(GREY50);
  431. #else
  432.     color(GREY25);
  433. #endif
  434.     bgntmesh();
  435.     v[0] = 0.3*DIM;
  436.     v[1] = 0.3*WALL_HT_0;
  437.     v3f(v);
  438.     v[1] = 0.8*WALL_HT_0;
  439.     v3f(v);
  440.     v[0] = 0.1*DIM;
  441.     v3f(v);
  442.     endtmesh();
  443.  
  444.     /* shape out to one side */
  445. #ifdef RGB_MODE
  446.     cpack(0x333333);
  447. #else
  448.     color(GREY50);
  449. #endif
  450.     bgntmesh();
  451.     v[0] = DIM;
  452.     v[1] = 0.0;
  453.     v3f(v);
  454.     v[0] = 1.5*DIM;
  455.     v[1] = 0.3*WALL_HT_0;
  456.     v3f(v);
  457. #ifdef RGB_MODE
  458.     cpack(0x666666);
  459. #endif
  460.     v[0] = DIM;
  461.     v[1] = WALL_HT_0;
  462.     v3f(v);
  463.     v[0] = 1.5*DIM;
  464.     v[1] = 0.7*WALL_HT_0;
  465.     v3f(v);
  466.     endtmesh();
  467.  
  468.     /* top rightangle */
  469. #ifdef RGB_MODE
  470.     cpack(0xffffff);
  471. #else
  472.     color(WHITE);
  473. #endif
  474.     bgnline();
  475.     v[0] = 0.4*DIM;
  476.     v[1] = WALL_HT_0;
  477.     v3f(v);
  478.     v[1] = 0.7*WALL_HT_0;
  479.     v3f(v);
  480.     v[0] = 1.5*DIM;
  481.     v3f(v);
  482.     endline();
  483.     bgnline();
  484.     v[0] = 0.6*DIM;
  485.     v[1] = WALL_HT_0;
  486.     v3f(v);
  487.     v[1] = 0.9*WALL_HT_0;
  488.     v3f(v);
  489.     v[0] = 1.15*DIM;
  490.     v3f(v);
  491.     endline();
  492.  
  493.     /* bottom corner shaded dark box */
  494. #ifdef RGB_MODE
  495.     cpack(0x666666);
  496. #else
  497.     color(GREY25);
  498. #endif
  499.     bgntmesh();
  500.     v[0] = 0.5*DIM;
  501.     v[1] = 0.0;
  502.     v3f(v);
  503.     v[0] = 0.8*DIM;
  504.     v3f(v);
  505. #ifdef RGB_MODE
  506.     cpack(0x333333);
  507. #endif
  508.     v[0] = 0.5*DIM;
  509.     v[1] = 0.5*WALL_HT_0;
  510.     v3f(v);
  511.     v[0] = 0.8*DIM;
  512.     v3f(v);
  513.     endtmesh();
  514.  
  515.     zbuffer(TRUE);
  516.     }
  517.     closeobj();
  518.  
  519.     /*
  520.      * roughly hexagon
  521.      */
  522.     makeobj(back_stuff[1]);
  523.     {
  524.     float v[3];
  525.  
  526.     v[2] = DIM;
  527.  
  528.     zbuffer(FALSE);
  529.  
  530.     /* big wall */
  531. #ifdef RGB_MODE
  532.     cpack(0x808080);
  533. #else
  534.     color(GREY50);
  535. #endif
  536.     bgntmesh();
  537.     v[0] = 1.15*DIM;
  538.     v[1] = 0.25*WALL_HT_1;
  539. #ifdef RGB_MODE
  540.     cpack(0x444444);
  541. #endif
  542.     v3f(v);
  543.     v[0] = 0.85*DIM;
  544.     v[1] = 0.85*WALL_HT_1;
  545. #ifdef RGB_MODE
  546.     cpack(0x808080);
  547. #endif
  548.     v3f(v);
  549.     v[0] = 0.4*DIM;
  550.     v[1] = 0.0;
  551. #ifdef RGB_MODE
  552.     cpack(0x222222);
  553. #endif
  554.     v3f(v);
  555.     v[0] = 0.69*DIM;
  556.     v[1] = 0.9*WALL_HT_1;
  557. #ifdef RGB_MODE
  558.     cpack(0x808080);
  559. #endif
  560.     v3f(v);
  561.     v[0] = -0.4*DIM;
  562.     v[1] = 0.0;
  563. #ifdef RGB_MODE
  564.     cpack(0x222222);
  565. #endif
  566.     v3f(v);
  567.     v[0] = 0.3*DIM;
  568.     v[1] = 0.55*WALL_HT_1;
  569. #ifdef RGB_MODE
  570.     cpack(0x808080);
  571. #endif
  572.     v3f(v);
  573.     v[0] = -1.0*DIM;
  574.     v[1] = 0.2*WALL_HT_1;
  575. #ifdef RGB_MODE
  576.     cpack(0x444444);
  577. #endif
  578.     v3f(v);
  579.     v[0] = -0.35*DIM;
  580.     v[1] = 1.0*WALL_HT_1;
  581. #ifdef RGB_MODE
  582.     cpack(0x808080);
  583. #endif
  584.     v3f(v);
  585.     v[0] = -0.65*DIM;
  586.     v[1] = 0.9*WALL_HT_1;
  587.     v3f(v);
  588.     v[0] = -0.4*DIM;
  589.     v[1] = 1.0*WALL_HT_1;
  590.     v3f(v);
  591.     endtmesh();
  592.  
  593.     /* two left side polygons  */
  594. #ifdef RGB_MODE
  595.     cpack(0x3f3f3f);
  596. #endif
  597.     bgnpolygon();
  598.     v[0] = -0.8*DIM;
  599.     v[1] = 0.6*WALL_HT_1;
  600.     v3f(v);
  601.     v[0] = -1.3*DIM;
  602.     v3f(v);
  603.     v[1] = 0.9*WALL_HT_1;
  604.     v3f(v);
  605.     v[0] = -0.45*DIM;
  606.     v[1] = 1.2*WALL_HT_1;
  607.     v3f(v);
  608.     endpolygon();
  609.  
  610. #ifdef RGB_MODE
  611.     cpack(0x4b4b4b);
  612. #endif
  613.     bgnpolygon();
  614.     v[0] = -0.8*DIM;
  615.     v[1] = 0.6*WALL_HT_1;
  616.     v3f(v);
  617.     v[0] = -1.3*DIM;
  618.     v3f(v);
  619. #ifdef RGB_MODE
  620.     cpack(0x606060);
  621. #endif
  622.     v[1] = 0.3*WALL_HT_1;
  623.     v3f(v);
  624.     v[0] = -1.0*DIM;
  625.     v[1] = 0.2*WALL_HT_1;
  626.     v3f(v);
  627.     endpolygon();
  628.  
  629.     /* white lines */
  630. #ifdef RGB_MODE
  631.     cpack(0xffffff);
  632. #endif
  633.     bgnline();
  634.     v[0] = -1.3*DIM;
  635.     v[1] = 0.6*WALL_HT_1;
  636.     v3f(v);
  637.     v[0] = -0.4*DIM;
  638.     v3f(v);
  639.     v[1] = 0.5*WALL_HT_1;
  640.     v3f(v);
  641.     v[0] = -0.85*DIM;
  642.     v[1] = 0.5*WALL_HT_1;
  643.     v3f(v);
  644.     endline();
  645.  
  646.     /* doorthingo  */
  647.     bgnpolygon();
  648.     v[0] = 0.25*DIM;
  649.     v[1] = 0.5*WALL_HT_1;
  650.     cpack(0x9e9e9e);
  651.     v3f(v);
  652.     v[0] = -0.25*DIM;
  653.     v3f(v);
  654.     v[0] = -0.2*DIM;
  655.     v[1] = 0.0;
  656.     cpack(0x555555);
  657.     v3f(v);
  658.     v[0] = 0.2*DIM;
  659.     v3f(v);
  660.     endpolygon();
  661.  
  662.     /*
  663.      * 2 black triangles
  664.      */
  665. #ifdef RGB_MODE
  666.         cpack(0);
  667. #endif
  668.         bgntmesh();
  669.         v[0] = -0.5*DIM;
  670.         v[1] = 0.2*WALL_HT_1;
  671.         v3f(v);
  672.         v[0] = -0.3*DIM;
  673.         v3f(v);
  674.         v[1] = 0.4*WALL_HT_1;
  675.         v3f(v);
  676.         endtmesh();
  677.  
  678.         bgntmesh();
  679.         v[0] = -0.3*DIM;
  680.         v[1] = 0.45*WALL_HT_1;
  681.         v3f(v);
  682.         v[0] = -0.5*DIM;
  683.         v3f(v);
  684.         v[1] = 0.25*WALL_HT_1;
  685.         v3f(v);
  686.         endtmesh();
  687.  
  688.     /* top polygon and triangle */
  689. #ifdef RGB_MODE
  690.     cpack(0x707070);
  691. #endif
  692.     bgnpolygon();
  693.     v[0] = 0.06*DIM;
  694.     v[1] = 0.71*WALL_HT_1;
  695.     v3f(v);
  696.     v[0] = 0.35*DIM;
  697.     v[1] = 0.5*WALL_HT_1;
  698.     v3f(v);
  699. #ifdef RGB_MODE
  700.     cpack(0x565656);
  701. #endif
  702.     v[0] = 0.69*DIM;
  703.     v[1] = 0.9*WALL_HT_1;
  704.     v3f(v);
  705. #ifdef RGB_MODE
  706.     cpack(0x505050);
  707. #endif
  708.     v[0] = 0.4*DIM;
  709.     v[1] = 1.0*WALL_HT_1;
  710.     v3f(v);
  711.     v[0] = 0.35*DIM;
  712.     v3f(v);
  713.     endpolygon();
  714.  
  715. #if 0
  716. #ifdef RGB_MODE
  717.     cpack(0x1a1a1a);
  718. #else
  719.     color(GREY25);
  720. #endif
  721.     bgntmesh();
  722.     v[0] = -0.35*DIM;
  723.     v[1] = 1.0*WALL_HT_1;
  724.     v3f(v);
  725.     v[0] = 0.35*DIM;
  726.     v3f(v);
  727.     v[0] = 0.06*DIM;
  728.     v[1] = 0.71*WALL_HT_1;
  729.     v3f(v);
  730.     endtmesh();
  731. #endif
  732.  
  733. #ifdef RGB_MODE
  734.     cpack(0xffffff);
  735. #endif
  736.     bgnline();
  737.     v[0] = 0.35*DIM;
  738.     v[1] = 0.5*WALL_HT_1;
  739.     v3f(v);
  740.     v[0] = -0.35*DIM;
  741.     v[1] = 1.0*WALL_HT_1;
  742.     v3f(v);
  743.     endline();
  744.  
  745.     /* dark strip to left with white highlights */
  746. #ifdef RGB_MODE
  747.     cpack(0x232323);
  748. #endif
  749.     bgnpolygon();
  750.     v[0] = 0.231*DIM;
  751.     v[1] = 0.0;
  752.     v3f(v);
  753.     v[0] = 0.3*DIM;
  754.     v3f(v);
  755.     v[0] = 1.07*DIM;
  756.     v[1] = 0.42*WALL_HT_1;
  757.     v3f(v);
  758.     v[0] = 1.0*DIM;
  759.     v[1] = 0.56*WALL_HT_1;
  760.     v3f(v);
  761.     endpolygon();
  762.  
  763. #ifdef RGB_MODE
  764.     cpack(0xffffff);
  765. #else
  766.     color(WHITE);
  767. #endif
  768.     bgnline();
  769.     v[0] = 0.231*DIM;
  770.     v[1] = 0.0;
  771.     v3f(v);
  772.     v[0] = 1.0*DIM;
  773.     v[1] = 0.56*WALL_HT_1;
  774.     v3f(v);
  775.     endline();
  776.  
  777. #ifdef RGB_MODE
  778.     cpack(0xffffff);
  779. #else
  780.     color(WHITE);
  781. #endif
  782.     bgnline();
  783.     v[0] = 0.3*DIM;
  784.     v[1] = 0.0;
  785.     v3f(v);
  786.     v[0] = 1.07*DIM;
  787.     v[1] = 0.42*WALL_HT_1;
  788.     v3f(v);
  789.     endline();
  790.  
  791.     /* polygon to right */
  792. #ifdef RGB_MODE
  793.     cpack(0x393939);
  794. #endif
  795.     bgnpolygon();
  796.     v[0] = 1.3*DIM;
  797.     v[1] = 0.7*WALL_HT_1;
  798.     v3f(v);
  799.     v[1] = 0.3*WALL_HT_1;
  800.     v3f(v);
  801.     v[0] = 1.15*DIM;
  802.     v[1] = 0.25*WALL_HT_1;
  803.     v3f(v);
  804.     v[0] = 0.85*DIM;
  805.     v[1] = 0.85*WALL_HT_1;
  806.     v3f(v);
  807.     endpolygon();
  808.  
  809.     /* silly offsided square things */
  810.     pushmatrix();
  811.     translate(-0.4*DIM, 0.0, 0.0);
  812.     rot(-19.0, 'z');
  813.  
  814. #ifdef RGB_MODE
  815.     cpack(0x4e4e4e);
  816. #endif
  817.     bgnpolygon();
  818.     v[0] = -0.25*DIM;
  819.     v[1] = 0.0;
  820.     v3f(v);
  821.     v[0] = -0.45*DIM;
  822.     v[1] = 0.0;
  823.     v3f(v);
  824.     v[0] = -0.45*DIM;
  825.     v[1] = 0.18*WALL_HT_1;
  826.     v3f(v);
  827.     v[0] = -0.25*DIM;
  828.     v[1] = 0.18*WALL_HT_1;
  829.     v3f(v);
  830.     endpolygon();
  831.  
  832.     bgnpolygon();
  833.     v[0] = -0.25*DIM;
  834.     v[1] = 0.31*WALL_HT_1;;
  835.     v3f(v);
  836.     v[0] = -0.45*DIM;
  837.     v[1] = 0.31*WALL_HT_1;;
  838.     v3f(v);
  839.     v[0] = -0.45*DIM;
  840.     v[1] = 0.52*WALL_HT_1;
  841.     v3f(v);
  842.     v[0] = -0.25*DIM;
  843.     v[1] = 0.52*WALL_HT_1;
  844.     v3f(v);
  845.     endpolygon();
  846.  
  847.     bgnpolygon();
  848.     v[0] = -0.25*DIM;
  849.     v[1] = 0.6*WALL_HT_1;;
  850.     v3f(v);
  851.     v[0] = -0.45*DIM;
  852.     v[1] = 0.6*WALL_HT_1;;
  853.     v3f(v);
  854.     v[0] = -0.45*DIM;
  855.     v[1] = 0.8*WALL_HT_1;
  856.     v3f(v);
  857.     v[0] = -0.25*DIM;
  858.     v[1] = 0.8*WALL_HT_1;
  859.     v3f(v);
  860.     endpolygon();
  861.  
  862.     zbuffer(TRUE);
  863.     popmatrix();
  864.  
  865.     }
  866.     closeobj();
  867.  
  868.     /*
  869.      * 2 huge trangles
  870.      */
  871.     makeobj(back_stuff[2]);
  872.     {
  873.     float v[3];
  874.  
  875.     v[2] = DIM;
  876.  
  877.     zbuffer(FALSE);
  878. /*
  879.  *****************middle box
  880.  */
  881.  
  882. #ifdef RGB_MODE
  883.     cpack(0);
  884. #endif
  885.     bgntmesh();
  886.     v[0] = 0.3*DIM;
  887.     v[1] = 0.38*WALL_HT_2;
  888.     v3f(v);
  889.     v[1] = 0.0;
  890.     v3f(v);
  891. #ifdef RGB_MODE
  892.     cpack(0xcccccc);
  893. #endif
  894.     
  895.     v[0] = -0.3*DIM;
  896.     v[1] = 0.38*WALL_HT_2;
  897.     v3f(v);
  898.     v[1] = 0.0;
  899.     v3f(v);
  900.     endtmesh();    
  901.  
  902. /*
  903.  ****************left maintriangle
  904.  */
  905.  
  906. #ifdef RGB_MODE
  907.     cpack(0x666666);
  908. #else
  909.     color(GREY50);
  910. #endif
  911.     bgntmesh();
  912.     v[0] = -1.0*DIM;
  913.     v[1] = 1.0*WALL_HT_2;
  914.     v3f(v);
  915.     v[0] = 0.0*DIM;
  916.     v3f(v);
  917. #ifdef RGB_MODE
  918.     cpack(0x333333);
  919. #endif
  920.     v[0] = -0.5*DIM;
  921.     v[1] = 0.0;
  922.     v3f(v);
  923.     endtmesh();
  924.  
  925. /*
  926.  * ****************connecting strip
  927.  */
  928.  
  929. #ifdef RGB_MODE
  930.     cpack(0x888888);
  931. #endif
  932.     bgnpolygon();
  933.     v[0] = 0.3*DIM;
  934.     v[1] = 0.25*WALL_HT_2;
  935.     v3f(v);
  936.     v[0] = 0.4*DIM;
  937.     v[1] = 0.4*WALL_HT_2;
  938.     v3f(v);
  939. #ifdef RGB_MODE
  940.     cpack(0x1e1e1e);
  941. #endif
  942.     v[0] = -0.4*WALL_HT_2;
  943.     v[1] = 1.0*WALL_HT_2;
  944.     v3f(v);
  945.     v[0] = -0.7*DIM;
  946.     v3f(v);
  947.     endpolygon();
  948. /*
  949.  *********************right main triangle
  950.  */
  951. #ifdef RGB_MODE
  952.     cpack(0x666666);
  953. #endif
  954.     bgntmesh();
  955.     v[0] = 0.1*DIM;
  956.     v[1] = 0.0;
  957.     v3f(v);
  958. #ifdef RGB_MODE
  959.     cpack(0x333333);
  960. #endif
  961.     v[0] = 1.5*DIM;
  962.     v3f(v);
  963. #ifdef RGB_MODE
  964.     cpack(0x666666);
  965. #endif
  966.     v[0] = 0.6*DIM;
  967.     v[1] = 0.8*WALL_HT_2;
  968.     v3f(v);
  969.     endtmesh();
  970. /*
  971.  * ************box in right triangle & its lines
  972.  */
  973.  
  974. #ifdef RGB_MODE
  975.     cpack(0xffffff);
  976. #endif
  977.  
  978.     bgnline();
  979.     v[0] = 0.75*DIM;
  980.     v[1] = 0.35*WALL_HT_2;
  981.     v3f(v);
  982.     v[0] = 1.0*DIM;
  983.     v[1] = 0.6*WALL_HT_2;
  984.     v3f(v);
  985.     v[0] = 5.0*DIM;
  986.     v[1] = 0.6*WALL_HT_2;
  987.     v3f(v);
  988.     endline();
  989.  
  990.     bgnline();
  991.     v[0] = 0.75*DIM;
  992.     v[1] = 0.27*WALL_HT_2;
  993.     v3f(v);
  994.     v[0] = 1.05*DIM;
  995.     v[1] = 0.55*WALL_HT_2;
  996.     v3f(v);
  997.     v[0] = 5.0*WALL_HT_2;
  998.     v[1] = 0.55*DIM;
  999.     v3f(v);
  1000.     endline();
  1001.     
  1002.  
  1003. #ifdef RGB_MODE
  1004.     cpack(0x0d0d0d);
  1005. #endif
  1006.     bgnpolygon();
  1007.     v[0] = 0.5*DIM;
  1008.     v[1] = 0.1*WALL_HT_2;
  1009.     v3f(v);
  1010.     v[0] = 0.75*DIM;
  1011.     v3f(v);
  1012.     v[1] = 0.4*WALL_HT_2;
  1013.     v3f(v);
  1014.     v[0] = 0.5*DIM;
  1015.     v3f(v);
  1016.     endpolygon();
  1017.  
  1018. /*
  1019.  * **************beams right triangle
  1020.  */
  1021.  
  1022.  
  1023. #ifdef RGB_MODE
  1024.     cpack(0x888888);
  1025. #endif
  1026.     bgntmesh();
  1027.     v[0] = 0.7*DIM;
  1028.     v[1] = 0.0;
  1029.     v3f(v);
  1030.     v[0] = 0.85*DIM;
  1031.     v3f(v);
  1032.     v[0] = 1.1*DIM;
  1033.     v[1] = 0.45*DIM;
  1034.     v3f(v);
  1035.     v[0] = 1.2*WALL_HT_2;
  1036.     v[1] = 0.4*WALL_HT_2;
  1037.     v3f(v);
  1038.     v[0] = 5.0*WALL_HT_2;
  1039.     v[1] = 0.45*DIM;
  1040.     v3f(v);
  1041.     v[0] = 5.0*WALL_HT_2;
  1042.     v[1] = 0.4*WALL_HT_2;
  1043.     v3f(v);
  1044.     endtmesh();
  1045.  
  1046. /*
  1047.  *********************shoots up left triangle
  1048.  */
  1049. #ifdef RGB_MODE
  1050.     cpack(0xffffff);
  1051. #endif
  1052.  
  1053.     bgntmesh();
  1054.     v[0] = -0.55*DIM;
  1055.     v[1] = 0.3*WALL_HT_2;
  1056.     v3f(v);
  1057.     v[0] = -0.53*DIM;
  1058.     v[1] = 0.3*WALL_HT_2;
  1059.     v3f(v);
  1060.     v[0] = -0.5*DIM;
  1061.     v[1] = 0.4*WALL_HT_2;
  1062.     v3f(v);
  1063.     endtmesh();
  1064.     bgntmesh();
  1065.     v[0] = -0.45*DIM;
  1066.     v[1] = 0.3*WALL_HT_2;
  1067.     v3f(v);
  1068.     v[0] = -0.47*DIM;
  1069.     v[1] = 0.3*WALL_HT_2;
  1070.     v3f(v);
  1071.     v[0] = -0.5*DIM;
  1072.     v[1] = 0.4*WALL_HT_2;
  1073.     v3f(v);
  1074.     endtmesh();
  1075.  
  1076.     bgntmesh();
  1077.     v[0] = -0.55*DIM;
  1078.     v[1] = 0.5*WALL_HT_2;
  1079.     v3f(v);
  1080.     v[0] = -0.53*DIM;
  1081.     v[1] = 0.5*WALL_HT_2;
  1082.     v3f(v);
  1083.     v[0] = -0.5*DIM;
  1084.     v[1] = 0.6*WALL_HT_2;
  1085.     v3f(v);
  1086.     endtmesh();
  1087.     bgntmesh();
  1088.     v[0] = -0.45*DIM;
  1089.     v[1] = 0.5*WALL_HT_2;
  1090.     v3f(v);
  1091.     v[0] = -0.47*DIM;
  1092.     v[1] = 0.5*WALL_HT_2;
  1093.     v3f(v);
  1094.     v[0] = -0.5*DIM;
  1095.     v[1] = 0.6*WALL_HT_2;
  1096.     v3f(v);
  1097.     endtmesh();
  1098.  
  1099.     bgntmesh();
  1100.     v[0] = -0.55*DIM;
  1101.     v[1] = 0.7*WALL_HT_2;
  1102.     v3f(v);
  1103.     v[0] = -0.53*DIM;
  1104.     v[1] = 0.7*WALL_HT_2;
  1105.     v3f(v);
  1106.     v[0] = -0.5*DIM;
  1107.     v[1] = 0.8*WALL_HT_2;
  1108.     v3f(v);
  1109.     endtmesh();
  1110.     bgntmesh();
  1111.     v[0] = -0.45*DIM;
  1112.     v[1] = 0.7*WALL_HT_2;
  1113.     v3f(v);
  1114.     v[0] = -0.47*DIM;
  1115.     v[1] = 0.7*WALL_HT_2;
  1116.     v3f(v);
  1117.     v[0] = -0.5*DIM;
  1118.     v[1] = 0.8*WALL_HT_2;
  1119.     v3f(v);
  1120.     endtmesh();
  1121.  
  1122.     zbuffer(TRUE);
  1123.     }
  1124.     closeobj();
  1125. }
  1126.  
  1127.  
  1128. /*
  1129.  * Draw the game grid
  1130.  */
  1131. void draw_coloured_grid(int level) {
  1132.     float i;
  1133.     float start[3], end[3], v1[3], v2[3], v4[3], v[3];
  1134.  
  1135. #ifdef RGB_MODE
  1136.     /* draw a polygonal background */
  1137.     cpack(0x330000);
  1138.  
  1139.     /* floor */
  1140.     bgnpolygon();
  1141.     v1[0] = -DIM;
  1142.     v1[1] = 0.0;
  1143.     v1[2] = -DIM;
  1144.     v3f(v1);
  1145.     v1[0] = DIM;
  1146.     v3f(v1);
  1147.     v1[2] = DIM;
  1148.     v3f(v1);
  1149.     v1[0] = -DIM;
  1150.     v3f(v1);
  1151.     endpolygon();
  1152.  
  1153.     /* walls */
  1154.     cpack(0x333333);
  1155.     bgntmesh();
  1156.     v1[0] = -DIM;
  1157.     v1[1] = 0.0;
  1158.     v1[2] = -DIM;
  1159.     v3f(v1);
  1160.     v1[1] = 10.0;
  1161.     v3f(v1);
  1162.  
  1163.     v1[0] = DIM;
  1164.     v1[1] = 0.0;
  1165.     v3f(v1);
  1166.     v1[1] = 10.0;
  1167.     v3f(v1);
  1168.  
  1169.     v1[2] = DIM;
  1170.     v1[1] = 0.0;
  1171.     v3f(v1);
  1172.     v1[1] = 10.0;
  1173.     v3f(v1);
  1174.  
  1175.     v1[0] = -DIM;
  1176.     v1[1] = 0.0;
  1177.     v3f(v1);
  1178.     v1[1] = 10.0;
  1179.     v3f(v1);
  1180.  
  1181.     v1[2] = -DIM;
  1182.     v1[1] = 0.0;
  1183.     v3f(v1);
  1184.     v1[1] = 10.0;
  1185.     v3f(v1);
  1186.     endtmesh();
  1187.  
  1188.     zbuffer(FALSE);
  1189. #endif
  1190.  
  1191.     /*
  1192.      * draw holes for level changes
  1193.      */
  1194. #ifdef RGB_MODE
  1195.     cpack(0xffffff);
  1196. #else
  1197.     color(WHITE);
  1198. #endif
  1199.  
  1200.     /* up hole */
  1201.     bgntmesh();
  1202.     v[0] = up_hole[level].x - HOLE_SIZE;
  1203.     v[1] = 0.0;
  1204.     v[2] = up_hole[level].z - HOLE_SIZE;
  1205.     v3f(v);
  1206.     /* centre */
  1207. #ifdef RGB_MODE
  1208.     cpack(level_col[(level+LEVELS-1)%LEVELS]);
  1209. #endif
  1210.     v[0] = up_hole[level].x;
  1211.     v[2] = up_hole[level].z;
  1212.     v3f(v);
  1213. #ifdef RGB_MODE
  1214.     cpack(0xffffff);
  1215. #endif
  1216.     v[0] = up_hole[level].x + HOLE_SIZE;
  1217.     v[2] = up_hole[level].z - HOLE_SIZE;
  1218.     v3f(v);
  1219.     swaptmesh();
  1220.     v[0] = up_hole[level].x + HOLE_SIZE;
  1221.     v[2] = up_hole[level].z + HOLE_SIZE;
  1222.     v3f(v);
  1223.     swaptmesh();
  1224.     v[0] = up_hole[level].x - HOLE_SIZE;
  1225.     v[2] = up_hole[level].z + HOLE_SIZE;
  1226.     v3f(v);
  1227.     swaptmesh();
  1228.     v[0] = up_hole[level].x - HOLE_SIZE;
  1229.     v[2] = up_hole[level].z - HOLE_SIZE;
  1230.     v3f(v);
  1231.     endtmesh();
  1232.  
  1233.     /* down hole */
  1234.     bgntmesh();
  1235.     v[0] = down_hole[level].x - HOLE_SIZE;
  1236.     v[1] = 0.0;
  1237.     v[2] = down_hole[level].z - HOLE_SIZE;
  1238.     v3f(v);
  1239.     /* centre */
  1240. #ifdef RGB_MODE
  1241.     cpack(level_col[(level+1)%LEVELS]);
  1242. #endif
  1243.     v[0] = down_hole[level].x;
  1244.     v[2] = down_hole[level].z;
  1245.     v3f(v);
  1246. #ifdef RGB_MODE
  1247.     cpack(0xffffff);
  1248. #endif
  1249.     v[0] = down_hole[level].x + HOLE_SIZE;
  1250.     v[2] = down_hole[level].z - HOLE_SIZE;
  1251.     v3f(v);
  1252.     swaptmesh();
  1253.     v[0] = down_hole[level].x + HOLE_SIZE;
  1254.     v[2] = down_hole[level].z + HOLE_SIZE;
  1255.     v3f(v);
  1256.     swaptmesh();
  1257.     v[0] = down_hole[level].x - HOLE_SIZE;
  1258.     v[2] = down_hole[level].z + HOLE_SIZE;
  1259.     v3f(v);
  1260.     swaptmesh();
  1261.     v[0] = down_hole[level].x - HOLE_SIZE;
  1262.     v[2] = down_hole[level].z - HOLE_SIZE;
  1263.     v3f(v);
  1264.     endtmesh();
  1265.  
  1266.  
  1267.  
  1268.     /* now draw the grid lines */
  1269. #ifdef RGB_MODE
  1270.     cpack(level_col[level]);
  1271. #else
  1272.     color(level_col[level]);
  1273. #endif
  1274.     start[1] = end[1] = 0.0;
  1275.     start[0] = -DIM;
  1276.     end[0] = DIM;
  1277.     v2[0] = -DIM;
  1278.     v2[1] = 10.0;
  1279.     v4[0] = DIM;
  1280.     v4[1] = 10.0;
  1281.     for (i = -DIM; i < DIM + 1.0; i += 10.0) {
  1282.     start[2] = end[2] = v2[2] = v4[2] = i;
  1283.     bgnline();
  1284.     v3f(v2);
  1285.     v3f(start);
  1286.     v3f(end);
  1287.     v3f(v4);
  1288.     endline();
  1289.     }
  1290.     start[2] = -DIM;
  1291.     end[2] = DIM;
  1292.     v2[2] = -DIM;
  1293.     v4[2] = DIM;
  1294.     for (i = -DIM; i < DIM + 1.0; i += 10.0) {
  1295.     start[0] = end[0] = v2[0] = v4[0] = i;
  1296.     bgnline();
  1297.     v3f(v2);
  1298.     v3f(start);
  1299.     v3f(end);
  1300.     v3f(v4);
  1301.     endline();
  1302.     }
  1303.     v1[0] = -DIM;
  1304.     v1[1] = 10.;
  1305.     v1[2] = -DIM;
  1306.     bgnclosedline();
  1307.     v3f(v1);
  1308.     v1[0] = DIM;
  1309.     v3f(v1);
  1310.     v1[2] = DIM;
  1311.     v3f(v1);
  1312.     v1[0] = -DIM;
  1313.     v3f(v1);
  1314.     endclosedline();
  1315. #ifdef RGB_MODE
  1316.     zbuffer(TRUE);
  1317. #endif
  1318. }
  1319.  
  1320.  
  1321. /*
  1322.  * draw a groovy spoked bulbous wheel
  1323.  */
  1324. void draw_wheel(int lo_res) {
  1325.     float v[3];
  1326.     register int i, j;
  1327.  
  1328.     if (2*CIRC_PTS > 255) {
  1329.         printf("too many tyre pts %d\n", 2*CIRC_PTS);
  1330.         exit(1);
  1331.     }
  1332.  
  1333. #ifdef RGB_MODE
  1334.     cpack(GREY100);
  1335. #else
  1336.     color(GREY25);
  1337. #endif
  1338.  
  1339.     /* tyre (CIRC_PTS*4 verts, CIRC_PTS*4 colours) */
  1340.     if (lo_res) {
  1341.         /* draw a flat top */
  1342.         bgntmesh();
  1343.         for (i = 0; i < CIRC_PTS; i++) {
  1344.         v3f(wheel_top[i*3]);
  1345.         v3f(wheel_top[i*3+2]);
  1346.         }
  1347.         endtmesh();
  1348.     }
  1349.     else {
  1350.         /* left side of tyre */
  1351.         bgntmesh();
  1352.         for (i = 0; i < CIRC_PTS; i++) {
  1353. #ifdef RGB_MODE
  1354.         cpack(GREY100);
  1355. #endif
  1356.         v3f(wheel_top[i*3]);
  1357. #ifdef RGB_MODE
  1358.         cpack(GREY150);
  1359. #endif
  1360.         v3f(wheel_top[i*3+1]);
  1361.         }
  1362.         endtmesh();
  1363.  
  1364.         /* right side of tyre */
  1365.         bgntmesh();
  1366.         for (i = 0; i < CIRC_PTS; i++) {
  1367. #ifdef RGB_MODE
  1368.         cpack(GREY150);
  1369. #endif
  1370.         v3f(wheel_top[i*3+1]);
  1371. #ifdef RGB_MODE
  1372.         cpack(GREY100);
  1373. #endif
  1374.         v3f(wheel_top[i*3+2]);
  1375.         }
  1376.         endtmesh();
  1377.     }
  1378.  
  1379. #ifdef FLAT_SIDES
  1380. /* CIRC_PTS*2 verts, 1 colour */
  1381.  
  1382. #ifdef RGB_MODE
  1383.     cpack(GREY50);
  1384. #else
  1385.     color(GREY50);
  1386. #endif
  1387.  
  1388.     pushmatrix();
  1389.     translate(WHEEL_WIDTH - 0.1, 0.0, 0.0);
  1390.     bgnpolygon();
  1391.     for (i = 0; i < CIRC_PTS; i++) v3f(wheel_side[i]);
  1392.     endpolygon();
  1393.     popmatrix();
  1394.  
  1395.     pushmatrix();
  1396.     translate(-WHEEL_WIDTH + 0.1, 0.0, 0.0);
  1397.     bgnpolygon();
  1398.     for (i = 0; i < CIRC_PTS; i++) v3f(wheel_side[i]);
  1399.     endpolygon();
  1400.     popmatrix();
  1401.  
  1402. #else
  1403. /* non flat sides */
  1404. /* CIRC_PTS*2 verts, 3 colours (SHADED_SPOKES: CIRC_PTS*2 colours) */
  1405.  
  1406.     v[1] = 0.0;
  1407.     v[2] = 0.0;
  1408.     /* one concave side wall */
  1409.     pushmatrix();
  1410.  
  1411.     translate(0.5*WHEEL_WIDTH + 0.05, 0.0, 0.0);
  1412.  
  1413. #ifdef SPOKES
  1414.     /* a few spokes */
  1415. #ifndef SHADED_SPOKES
  1416. #ifdef RGB_MODE
  1417.     cpack(GREY50);
  1418. #else
  1419.     color(WHITE);
  1420. #endif
  1421. #endif
  1422.     v[0] = -0.5*WHEEL_WIDTH;
  1423.     v[1] = v[2] = 0.0;
  1424.     for (j = 0; j < NUM_SPOKES; j++) {
  1425.         bgntmesh();
  1426. #ifdef SHADED_SPOKES
  1427.         cpack(GREY50);
  1428. #endif
  1429.         v3f(v);
  1430. #ifdef SHADED_SPOKES
  1431.         cpack(0xffffff);
  1432. #endif
  1433.         v3f(wheel_side[CIRC_PTS*j/NUM_SPOKES]);
  1434.         v3f(wheel_side[CIRC_PTS*j/NUM_SPOKES + CIRC_PTS/(3*NUM_SPOKES)]);
  1435.         endtmesh();
  1436.     }
  1437. #else
  1438.     /* solid concave wheel */
  1439.     bgntmesh();
  1440. #ifdef SHADED_SPOKES
  1441.     cpack(0);
  1442. #else
  1443. #ifdef RGB_MODE
  1444.     cpack(0);
  1445. #else
  1446.     color(GREY50);
  1447. #endif
  1448. #endif
  1449.     v3f(wheel_side[0]);
  1450.     cpack(0xffffff);
  1451.     /* wheel centre */
  1452.     v[0] = -0.5*WHEEL_WIDTH;
  1453.     v3f(v);
  1454. #ifndef SHADED_SPOKES
  1455. #ifdef RGB_MODE
  1456.     cpack(GREY50);
  1457. #else
  1458.     color(GREY50);
  1459. #endif
  1460. #endif
  1461.     for (i = 1; i < CIRC_PTS; i++) {
  1462. #ifdef SHADED_SPOKES
  1463.         cpack((i%2) ? GREY50 : 0);
  1464. #endif
  1465.         v3f(wheel_side[i]);
  1466.         swaptmesh();
  1467.     }
  1468.     endtmesh();
  1469. /* end spokes: */
  1470. #endif
  1471.     popmatrix();
  1472.  
  1473.     /* the other side wall */
  1474.     pushmatrix();
  1475.     translate(-0.5*WHEEL_WIDTH - 0.05, 0.0, 0.0);
  1476.  
  1477. #ifdef SPOKES
  1478.     /* a few spokes */
  1479. #ifndef SHADED_SPOKES
  1480. #ifdef RGB_MODE
  1481.     cpack(GREY50);
  1482. #else
  1483.     color(WHITE);
  1484. #endif
  1485. #endif
  1486.     v[0] = 0.5*WHEEL_WIDTH;
  1487.     v[1] = v[2] = 0.0;
  1488.     for (j = 0; j < NUM_SPOKES; j++) {
  1489.         bgntmesh();
  1490. #ifdef SHADED_SPOKES
  1491.     cpack(GREY50);
  1492. #endif
  1493.         v3f(v);
  1494. #ifdef SHADED_SPOKES
  1495.         cpack(0xffffff);
  1496. #endif
  1497.         v3f(wheel_side[CIRC_PTS*j/NUM_SPOKES]);
  1498.         v3f(wheel_side[CIRC_PTS*j/NUM_SPOKES + CIRC_PTS/(3*NUM_SPOKES)]);
  1499.         endtmesh();
  1500.     }
  1501. #else
  1502.     /* solid concave wheel */
  1503.     bgntmesh();
  1504. #ifdef SHADED_SPOKES
  1505.     cpack(0);
  1506. #else
  1507. #ifdef RGB_MODE
  1508.     cpack(0xdd1111);
  1509. #else
  1510.     color(BLUE);
  1511. #endif
  1512. #endif
  1513.     v3f(wheel_side[0]);
  1514. #ifdef RGB_MODE
  1515.     cpack(0xffffff);
  1516. #else
  1517.     color(WHITE);
  1518. #endif
  1519.     /* wheel centre */
  1520.     v[0] = 0.5*WHEEL_WIDTH;
  1521.     v3f(v);
  1522. #ifndef SHADED_SPOKES
  1523. #ifdef RGB_MODE
  1524.     cpack(0xdd1111);
  1525. #else
  1526.     color(BLUE);
  1527. #endif
  1528. #endif
  1529.     for (i = 1; i < CIRC_PTS; i++) {
  1530. #ifdef SHADED_SPOKES
  1531.         cpack((i%2) ? GREY50 : 0);
  1532. #endif
  1533.         v3f(wheel_side[i]);
  1534.         swaptmesh();
  1535.     }
  1536.     endtmesh();
  1537. /* end spokes: */
  1538. #endif
  1539.     popmatrix();
  1540. /* end not flat sides: */
  1541. #endif
  1542.  
  1543. #ifdef OUTLINING
  1544. #ifdef RGB_MODE
  1545.     cpack(0xffffff);
  1546. #else
  1547.     color(WHITE);
  1548. #endif
  1549.  
  1550.     pushmatrix();
  1551.     translate(WHEEL_WIDTH - 0.1, 0.0, 0.0);
  1552.     bgnline();
  1553.     for (i = 0; i < CIRC_PTS; i++) v3f(wheel_side[i]);
  1554.     endline();
  1555.     popmatrix();
  1556.  
  1557.     pushmatrix();
  1558.     translate(-WHEEL_WIDTH + 0.1, 0.0, 0.0);
  1559.     bgnline();
  1560.     for (i = 0; i < CIRC_PTS; i++) v3f(wheel_side[i]);
  1561.     endline();
  1562.     popmatrix();
  1563. #endif
  1564. }
  1565.  
  1566.  
  1567. void draw_cute_flag(int colour) {
  1568.     float v[3];
  1569.  
  1570. #ifdef RGB_MODE
  1571.     cpack(trail_col[colour]);
  1572. #else
  1573.     color(trail_col[colour]);
  1574. #endif
  1575.  
  1576.     v[0] = 0.0;
  1577.     v[2] = -0.1*CYCLE_LENGTH;
  1578.     bgnline();
  1579.     v[1] = 4.0;
  1580.     v3f(v);
  1581.     v[1] = 6.0;
  1582.     v3f(v);
  1583.     endline();
  1584.  
  1585.     bgntmesh();
  1586.     v3f(v);
  1587.     v[1] -= 0.5;
  1588.     v[2] += 1.0;
  1589.     v3f(v);
  1590.     v[1] -= 0.5;
  1591.     v[2] -= 1.0;
  1592.     v3f(v);
  1593.     endtmesh();
  1594. }
  1595.  
  1596.  
  1597. /*
  1598.  * draw a new cycle
  1599.  */
  1600. void draw_cycle(int id, float step, int colour, int lo_res, int robot, int flag_colour) {
  1601.     wheel_angle[id][0] += (int)(step*ROT_SPEED_REAR);
  1602.     wheel_angle[id][1] += (int)(step*ROT_SPEED_FRONT);
  1603.     wheel_angle[id][0] %= 3600;
  1604.     wheel_angle[id][1] %= 3600;
  1605.  
  1606.     pushmatrix();
  1607.     translate(0.0, 1.55, -1.3);
  1608.     rotate(-wheel_angle[id][0], 'x');
  1609.     draw_wheel(lo_res);
  1610.     popmatrix();
  1611.  
  1612.     pushmatrix();
  1613.     translate(0.0, 1.40, -6.4);
  1614.     rotate(-wheel_angle[id][1], 'x');
  1615.     scale(0.9, 0.9, 0.9);
  1616.     draw_wheel(lo_res);
  1617.     popmatrix();
  1618.  
  1619.     if (robot) draw_cute_flag(flag_colour);
  1620.  
  1621.     pushmatrix();
  1622.     callobj(tail_obj);
  1623.     callobj(engine_obj);
  1624.     callobj(chassis_top);
  1625.     popmatrix();
  1626. }
  1627.